//
//  RYJingduView.swift
//  SheYangBigData
//
//  Created by 宋海胜 on 2021/1/12.
//  Copyright © 2021 叁拾叁. All rights reserved.
//

import UIKit

class RYJingduView: SYBaseView {

    var totalWidth: CGFloat = 0.0
    var currentJindu: Double = 0.0 {
        didSet {
            let width: Double = Double((totalWidth*CGFloat(currentJindu)))
            current.snp.remakeConstraints { (make) in
                
                make.top.left.equalToSuperview()
                make.height.equalTo(8.autoWidth())
                make.width.equalTo(width.autoWidth())
            }
            let str = String(format: "%.2f", currentJindu*100)
            titleLb.text = "已认养\(str)%"
        }
    }
    
    var current: UIView = {
        let v: UIView = UIView()
        v.backgroundColor = UIColor(hex: 0xF55035)
        v.layer.cornerRadius = 4.autoWidth()
        return v
    }()
    
    var total: UIView = {
        let v: UIView = UIView()
        v.backgroundColor = UIColor(hex: 0xFFE3DF)
        v.layer.cornerRadius = 4.autoWidth()
        return v
    }()
    
    var titleLb: UILabel = {
        let v: UILabel = UILabel()
        v.font = 11.autoFontSize()
        v.textColor = UIColor(hex: 0xF55035)
        
        return v
    }()

    override func initViews() {
        
        addSubview(total)
        addSubview(current)
        addSubview(titleLb)
        total.snp.makeConstraints { (make) in
            make.top.left.right.equalToSuperview()
            make.height.equalTo(8.autoWidth())
        }
        current.snp.makeConstraints { (make) in
            make.top.left.equalToSuperview()
            make.height.equalTo(8.autoWidth())
            make.width.equalTo(8.autoWidth())
        }
        titleLb.snp.makeConstraints { (make) in
            make.top.equalTo(total.snp.bottom).offset(3)
            make.left.equalToSuperview()
            make.height.equalTo(11.autoWidth())
        }
        
        
    }

}


class RYJingduBigView: SYBaseView {

    var totalWidth: CGFloat = 0.0
    var currentJindu: Double = 0.0 {
        didSet {
            let width: Double = Double((totalWidth*CGFloat(currentJindu)))
            current.snp.remakeConstraints { (make) in
                
                make.top.left.equalToSuperview()
                make.height.equalTo(15.autoWidth())
                make.width.equalTo(width.autoWidth())
            }
            
            titleLb.text = "已认养\(currentJindu*100)%"
        }
    }
    
    var current: UIView = {
        let v: UIView = UIView()
        v.backgroundColor = UIColor(hex: 0xF55035)
        v.layer.cornerRadius = 7.5.autoWidth()
        return v
    }()
    
    var total: UIView = {
        let v: UIView = UIView()
        v.backgroundColor = UIColor(hex: 0xFFE3DF)
        v.layer.cornerRadius = 7.5.autoWidth()
        return v
    }()
    
    var titleLb: UILabel = {
        let v: UILabel = UILabel()
        v.font = 13.autoFontSize()
        v.textColor = UIColor(hex: 0xF55035)
        
        return v
    }()

    override func initViews() {
        
        addSubview(total)
        addSubview(current)
        addSubview(titleLb)
        total.snp.makeConstraints { (make) in
            make.top.left.right.equalToSuperview()
            make.height.equalTo(15.autoWidth())
        }
        current.snp.makeConstraints { (make) in
            make.top.left.equalToSuperview()
            make.height.equalTo(15.autoWidth())
            make.width.equalTo(15.autoWidth())
        }
        titleLb.snp.makeConstraints { (make) in
            make.top.equalTo(total.snp.bottom).offset(7)
            make.left.equalToSuperview()
            make.height.equalTo(13.autoWidth())
        }
        
        
    }

}
